﻿package com.codingbros.brogui
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.display.DisplayObject;
	
	/**
	 * ...
	 * @author Peter Tolstrup
	 */
	public class Main extends Sprite 
	{
		private var _testButton:BroButton;
		private var _testCheckBoxButton:BroCheckBoxButton;
		
		public function Main():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
			
			_testButton = new BroButton(100, 20, "test knap");
			_testButton.x = 20;
			_testButton.y = 20;
			_testButton.name = "testButton";
			addChild(_testButton);			
			_testButton.addEventListener(MouseEvent.MOUSE_OVER, onOver);
			_testButton.addEventListener(MouseEvent.MOUSE_OUT, onOut);
			_testButton.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
			
			_testCheckBoxButton = new BroCheckBoxButton(150, 20, "test checkBox knap");
			_testCheckBoxButton.x = 20;
			_testCheckBoxButton.y = 120;
			_testCheckBoxButton.name = "testCheckBoxButton";
			addChild(_testCheckBoxButton);			
			_testCheckBoxButton.addEventListener(MouseEvent.MOUSE_OVER, onOver);
			_testCheckBoxButton.addEventListener(MouseEvent.MOUSE_OUT, onOut);
			_testCheckBoxButton.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
		}
		
		private function onOver(e:MouseEvent):void
		{
			trace("over on: " + e.target.name);
		}
		
		private function onOut(e:MouseEvent):void 
		{
			trace("out from: " + e.target.name);
		}
		
		private function onDown(e:MouseEvent):void
		{
			trace("down on: " + e.target.name);
		}
		
	}
	
}